<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('rd_alarm_danger', function (Blueprint $table) {
            $table->comment('隐患信息');
            $table->bigIncrements('id');
            $table->unsignedInteger('type')->comment('隐患类型');
            $table->unsignedBigInteger('stand_id')->comment('站点ID');
            $table->unsignedBigInteger('camera_id')->nullable()->comment('摄像头ID');
            $table->string('addr', 255)->nullable()->comment('发现位置');
            $table->unsignedInteger('from_type')->comment('工单类型1:AI隐患2:拍照识别3:人工上报');
            $table->unsignedTinyInteger('severity')->comment('隐患严重程度1:普通2:紧急3:非常紧急');
            $table->json('extra')->nullable()->comment('附加信息');
            $table->unsignedTinyInteger('is_work')->default(2)->comment('是否提报工单1:是2:否');
            $table->authorBy();
            $table->timestamps();
            $table->index('type', 'idx_type');
            $table->index('stand_id', 'idx_stand_id');
            $table->index('camera_id', 'idx_camera_id');
            $table->index('from_type', 'idx_from_type');
            $table->index('severity', 'idx_severity');
            $table->index('status', 'idx_status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('rd_alarm_danger');
    }
};